package com.yang.design.structure.decorator.example;

public class Client {
    public static void main(String[] args) {

        String info = "name:tom,age:15";

        //用基本功能进行读写
        DataLoader dataLoader = new BaseFileDataLoader("demo.txt");
        dataLoader.write(info);
        String read = dataLoader.read();
        System.out.println(read);

        //用装饰后的加密功能进行读写
        dataLoader = new EncryptionDataDecorator(new BaseFileDataLoader("demo2.txt"));//把被装饰者类传进去，
        dataLoader.write(info);
        read = dataLoader.read();
        System.out.println(read);

        //对于客户端来说，读和写是没有区分的，装饰后的和装饰前的是没有区别的
    }
}
